refactor: DRY audit page layout wrapper#47
Open
somethingwithproof wants to merge 1 commit intoCacti:developfrom
Open
refactor: DRY audit page layout wrapper#47somethingwithproof wants to merge 1 commit intoCacti:developfrom
somethingwithproof wants to merge 1 commit intoCacti:developfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors the audit plugin UI controller to remove duplicated top_header() / bottom_footer() page-wrapping logic by introducing a shared layout wrapper helper and routing relevant actions through it.
Changes:
- Added
audit_render_with_layout()helper to centralize audit page layout wrapping. - Updated
audit.phprouting to use the shared wrapper for thepurgeanddefaultpaths. - Added a standalone regression test to validate wrapper call ordering and ensure the routing uses the helper.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
ui_helpers.php |
Introduces shared audit_render_with_layout() wrapper around top_header() / renderer / bottom_footer(). |
audit.php |
Includes the helper and routes wrapped actions through it to eliminate duplicated layout code. |
tests/test_layout_wrapper.php |
Adds a lightweight regression script checking wrapper sequencing and basic routing wiring. |
You can also share your feedback on Copilot code review. Take the survey.
| */ | ||
|
|
||
| if (!function_exists('audit_render_with_layout')) { | ||
| function audit_render_with_layout($renderer) { |
Comment on lines
+53
to
+59
| assert_true( | ||
| 'purge/default actions use shared layout helper', | ||
| substr_count($source, "audit_render_with_layout('audit_log');") >= 2 | ||
| ); | ||
| assert_true( | ||
| 'audit.php includes ui helper file', | ||
| strpos($source, "include_once('./plugins/audit/ui_helpers.php');") !== false |
Comment on lines
+62
to
+65
| echo "\n"; | ||
| echo "Results: $pass passed, $fail failed\n"; | ||
|
|
||
| exit($fail > 0 ? 1 : 0); |
Comment on lines
+6
to
+11
| | This program is free software; you can redistribute it and/or | | ||
| | modify it under the terms of the GNU General Public License | | ||
| | as published by the Free Software Foundation; either version 2 | | ||
| | of the License, or (at your option) any later version. | | ||
| +-------------------------------------------------------------------------+ | ||
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
audit_render_with_layout()helper for page wrapper renderingtop_header()/bottom_footer()wrapper logicTests
php -l audit.phpphp -l ui_helpers.phpphp -l tests/test_layout_wrapper.phpphp tests/test_layout_wrapper.phpCloses #46